/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package it.polimi.games.epkb.manager;

import it.polimi.games.epkb.entityClasses.StoredValues;
import it.polimi.games.epkb.manager.EPKBmanager;
import java.math.BigDecimal;
import java.util.Date;

/**
 *
 * @author PoliMi
 */
public class Test {

        /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {

        ///////////////////////////////////////////////////////////////////
        // IMPORTANT!!!!!!!!!!!!!!!!!!!!!
        // Update information related to SQL connection (user, password, port)
        // in the persistence.xml file (Meta-INF folder)


        EPKBmanager eman = new EPKBmanager();


        String si="SInst1";
        String contextID="34";
        String gpiKpiId="1";
        BigDecimal num = null;
        StoredValues sv=null;

        // Examples of methods to retrieve information about stored values
        Date d = new Date();
        d.setYear(110);
        d.setMonth(11);
        d.setDate(22);
        d.setHours(11);
        d.setMinutes(8);
        d.setSeconds(24);

        
        //StoredValues v = eman.getIndicator("1", "BP1", d) ;
        //StoredValues v = eman.getLastValue("2") ;
        
        //for (int i=0; i<100; i++) {
        
        //    eman.insertRandomGPIKPIValue("CPU1", "2", new BigDecimal(0), new BigDecimal(100));
        //    eman.insertRandomGPIKPIValue("BP1", "1", new BigDecimal(600), new BigDecimal(1050));
        //    eman.insertRandomGPIKPIValue("SInst1", "1", new BigDecimal(600), new BigDecimal(1050));
        //    Thread.sleep(2000);
        
        //}

        // Examples of methods to retrieve information about resources allocation
        //System.out.println("#################  Cores..."+eman.getAllocatedCPUCores(si));
        //System.out.println("#################  DiskArray..."+eman.getAllocatedDiskArray(si));
        //System.out.println("#################  Mem..."+eman.getAllocatedMemory(si));


        // Example of method to insert a new computed GPI/KPI value
        //num= new BigDecimal(999.34);
        //eman.insertGPIKPIValue(si, gpiKpiId, contextID, num, eman.isRed(si, gpiKpiId, num), eman.isYellow(si, gpiKpiId, num));


        // Example of method to retrieve the last stored computed GPI/KPI value referred to a component
        //sv=eman.getLastValue(si, gpiKpiId);
        //System.out.println("Value..... " + sv.getValue());


        // Example of method to retrieve the list defined GPI/KPIs
       /**
        GpiKpiJpaController gpiKpiC = new GpiKpiJpaController();
        List<GpiKpi> l = gpiKpiC.findGpiKpiEntities();
        Iterator<GpiKpi> i = l.iterator();
        while (i.hasNext()) {
            GpiKpi gpiKpi = i.next();
            int id = gpiKpi.getId();
            String name = gpiKpi.getName();
            String type = gpiKpi.getType();
            System.out.println("GPI/KPI Id.... "+id+"     Name..... " + name + "      Type.... "+ type);
        }
     

        /**

        System.out.println(eman.isRed(si, gpiKpiId, new BigDecimal(3)));
        System.out.println(eman.isRed(si, gpiKpiId, new BigDecimal(6)));
        System.out.println(eman.isRed(si, gpiKpiId, new BigDecimal(11)));

        System.out.println(eman.isYellow(si, gpiKpiId, new BigDecimal(3)));
        System.out.println(eman.isYellow(si, gpiKpiId, new BigDecimal(6)));
        System.out.println(eman.isYellow(si, gpiKpiId, new BigDecimal(11)));
        **/

        //The following examples set threshold values


        /**
        
        // 0   0   30.5   40.8   GPI1 Green
        si="BP1";
        gpiKpiId="1";
        eman.setThreshold(si, gpiKpiId, BigDecimal.ZERO, BigDecimal.ZERO, new BigDecimal(30.5), new BigDecimal(40.8));


        // 0   0   20.5   40.8   GPI1 Yellow
        si="BP1";
        gpiKpiId="1";
        eman.setThreshold(si, gpiKpiId, BigDecimal.ZERO, BigDecimal.ZERO, new BigDecimal(20.5), new BigDecimal(40.8));


        // 0   0   15.5   20.0   GPI1 Red
        si="BP1";
        gpiKpiId="1";
        eman.setThreshold(si, gpiKpiId, BigDecimal.ZERO, BigDecimal.ZERO, new BigDecimal(15.5), new BigDecimal(20.0));


        //  0.4  0.6   1.0  1.0  GPI2 Green
        si="CPU1";
        gpiKpiId="2";
        eman.setThreshold(si, gpiKpiId, new BigDecimal(0.4), new BigDecimal(0.6), BigDecimal.ONE, BigDecimal.ONE);

        //  0.5  0.8   1.0  1.0  GPI2 Yellow
        si="CPU1";
        gpiKpiId="2";
        eman.setThreshold(si, gpiKpiId, new BigDecimal(0.5), new BigDecimal(0.8), BigDecimal.ONE, BigDecimal.ONE);


        //  0.8  0.9   1.0  1.0  GPI2 Red
        si="CPU1";
        gpiKpiId="2";
        eman.setThreshold(si, gpiKpiId, new BigDecimal(0.8), new BigDecimal(0.9), BigDecimal.ONE, BigDecimal.ONE);

        **/

       


    }



}
